<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>VueTest</title>
</head>
<body>
<!--view层，模板-->
<div id="ckr">
    <button v-on:click="greet">Greet</button>
    <!-- v-on 指令的简写形式 @ -->
    <button @click="greet">点我</button>
</div>

<!--1.导入Vue.js-->
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.min.js"></script>
<script type="text/javascript">
    let vue = new Vue({
        el: '#ckr',
        data: {
            name: 'Vue.js'
        },
        methods: {
            greet: function (event) {
                alert('Hello ' + this.name + '!')
                // `event` 是原生 DOM 事件
                if (event) {
                    alert(event.target.tagName)
                }
            }
        }
    });
</script>
</body>
</html>
